package com.aifast.crm.customer.controller;

import com.aifast.common.annotations.AiIdempotent;
import com.aifast.common.base.Controller;

import com.aifast.common.base.R;
import com.aifast.common.layui.LayuiDataTable;
import com.aifast.crm.customer.entity.CrmSeas;
import com.aifast.crm.customer.service.CrmSeasService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 公海数据 控制层
 *
 * @author fujian
 * @date 2022-08-24
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/crm/seas")
public class CrmSeasController extends Controller {
    private final CrmSeasService service;

    @GetMapping("list")
    public LayuiDataTable list() {
        return service.list(get("name"), getPage());
    }

    @AiIdempotent
    @PostMapping("add")
    public R add(@Valid CrmSeas crmSeas) {
        return service.insertOrUpdate(crmSeas) ? OK() : ERROR();
    }

    @AiIdempotent
    @GetMapping("del")
    public R del() {
        return service.del(getLong("id"), get("ids")) ? OK() : ERROR();
    }

    @GetMapping("info")
    public R info() {
        return service.info(getLong("id"));
    }


}
